package UI;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

import COMP.ImageComponent;
import COMP.imgBtn;

public class PopUpEconomics extends JDialog{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private ImageComponent bg = 
			new ImageComponent(new ImageIcon("Img/popup_economics_bg.png").getImage());
	private JRadioButton passive = new JRadioButton();
	private JRadioButton system = new JRadioButton();
	private JRadioButton light = new JRadioButton();
	private JRadioButton renewal = new JRadioButton();
	private imgBtn btnWindowsClose = new imgBtn("Img/chart_butt_x.png");
	private imgBtn btnWindowsIconified = new imgBtn("Img/chart_butt_-.png");
	private imgBtn closeBtn = new imgBtn("Img/factor_select_check.png");
	private JTextField percentage = new JTextField();
	private JLabel notice = new JLabel();
	private JFrame superclass;
	public PopUpEconomics(JFrame superclass, boolean passive, boolean system, boolean light, boolean renewal, int percentage) {
		super(superclass,true);
		this.superclass = superclass;
		this.passive.setSelected(passive);
		this.system.setSelected(system);
		this.light.setSelected(light);
		this.renewal.setSelected(renewal);
		this.percentage.setText(percentage+"");
		this.setUndecorated(true);		
		init();
	}
	
	private void init(){
		setSize(350,160);
		setLocationRelativeTo(null);
		getContentPane().setLayout(new BorderLayout());
		bg.setLayout(null);
		getContentPane().add("Center",bg);
		addComp();
	}
	private void addComp(){
		passive.setBounds(150,53,20,20);
		system.setBounds(150,77,20,20);
		light.setBounds(150,101,20,20);
		renewal.setBounds(150,123,20,20);
		percentage.setBounds(208,74,30,24);
		closeBtn.setBounds(294,120,32,22);
		bg.add(passive);
		bg.add(system);
		bg.add(light);
		bg.add(renewal);
		bg.add(percentage);
		bg.add(closeBtn);
		btnWindowsClose.setBounds(338,1,10,10);
		btnWindowsClose.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0) {
				closePopUp();
			}
			
		});
		bg.add(btnWindowsClose);
		btnWindowsIconified.setBounds(326, 1, 10, 10);
		btnWindowsIconified.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				superclass.setExtendedState(JFrame.ICONIFIED); 
			}

		});
		bg.add(btnWindowsIconified);
	}
	public void eventPassiveRBtn(ActionListener e){
		passive.addActionListener(e);		
	}
	public void eventSystemRBtn(ActionListener e){
		system.addActionListener(e);		
	}
	public void eventLightRBtn(ActionListener e){
		light.addActionListener(e);		
	}
	public void eventRenewalRBtn(ActionListener e){
		renewal.addActionListener(e);		
	}
	public void eventCloseBtn(ActionListener e){
		closeBtn.addActionListener(e);		
	}
	public void eventkeyListener(KeyAdapter e){
		percentage.addKeyListener(e);
	}
	public void setPercentage(String percent){
		percentage.setText(percent);
	}
	public String getPercentage(){
		return percentage.getText();
	}
	public void closePopUp(){
		this.dispose();
	}
	
}
